public class VarScope
{
	public static void main(String[] args)
	{
		Cat a = new Cat();
		a.hi(); 
	}
}

class Cat
{
	//全局变量也就是属性,作用域为整个类
	//属性在定义时可以直接赋值
	int age = 10;

	//全局变量可以不赋值,直接使用,因为有默认值
	double weight;

	public void hi()
	{
		//局部变量必须赋值后才能使用,因为没有默认值
		int num = 1;
		String address = "北京的猫";
		System.out.println("num = " + num);
		System.out.println("address = " + address);
		System.out.println("weight = " + weight);
	}
}